package com.cssw.fyzb.busi.api.user;

import com.cssw.fyzb.core.model.vo.user.SearchUserVo;
import com.cssw.fyzb.core.model.vo.user.UserForLiveVo;
import com.cssw.fyzb.busi.service.user.UserService;
import com.ydn.appserver.Action;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import com.ydn.appserver.annotations.Function;
import com.ydn.appserver.annotations.Parameter;
import com.ydn.appserver.annotations.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 直播间内查询用户信息
 * @author YangYiQun
 */
@Function(description = "查询用户列表", parameters = {
        @Parameter(name = "userId", type = Type.String, description = "用户标识", required = true),
        @Parameter(name = "liveId", type = Type.String, description = "直播间", required = true),
        @Parameter(name = "liveUserId", type = Type.String, description = "被查询用户标识", required = true)
})
@Component
public class GetUserForLive implements Action {

    private static final Logger logger = LoggerFactory.getLogger(GetUserForLive.class);

    @Autowired
    private UserService userService;

    @Override
    public Response execute(Request request) throws Exception {
        Long userId = request.getLong("userId");
        Long liveId = request.getLong("liveId");
        Long liveUserId = request.getLong("liveUserId");
        try {
            UserForLiveVo vo = userService.getUserForLive(userId, liveId, liveUserId);
            return Response.success().put("data", vo);
        } catch (Exception e) {
            logger.error("", e);
            return Response.fail("查询失败");
        }
    }
}
